<?php

declare(strict_types=1);

namespace Swb\Shop\Model;

use Hyperf\Cache\Annotation\Cacheable;
use Hyperf\DbConnection\Db;
use Hyperf\DbConnection\Model\Model as BaseModel;

/**
 * @property int $id
 * @property int $sort
 * @property int $parent_id
 * @property string $name
 * @property string $merger_name
 * @property string $short_name
 * @property string $merger_short_name
 * @property int $level_type
 * @property int $city_code
 * @property int $zip_code
 * @property string $pinyin
 * @property string $jianpin
 * @property string $first_char
 * @property float $longitude
 * @property float $latitude
 * @property string $remarks
 * @property string $create_by
 * @property string $create_time
 * @property string $update_by
 * @property string $update_time
 * @property int $del_flag
 */
class SysProvinceCity extends BaseModel
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'sys_province_city';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'int', 'sort' => 'integer', 'parent_id' => 'integer', 'level_type' => 'integer', 'city_code' => 'integer', 'zip_code' => 'integer', 'longitude' => 'float', 'latitude' => 'float', 'del_flag' => 'integer'];

    public function area()
    {
        return $this->hasMany(SysBusinessArea::class, 'area_id')
            ->where('del_flag', 1)
            ->select('name', 'id', 'area_id');
    }
}
